/* 
 * Copyright (C) 2002-2015 XimpleWare, info@ximpleware.com
 *
 * This program is free software; you can redistribute it and/or modify
 * it under the terms of the GNU General Public License as published by
 * the Free Software Foundation; either version 2 of the License, or
 * (at your option) any later version.
 *
 * This program is distributed in the hope that it will be useful,
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 * GNU General Public License for more details.
 *
 * You should have received a copy of the GNU General Public License
 * along with this program; if not, write to the Free Software
 * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
 */
/*VTD-XML is protected by US patent 7133857, 7260652, an 7761459*/
#pragma once
#ifndef INTHASH_H
#define INTHASH_H
#include "fastIntBuffer.h"

namespace com_ximpleware {
	class IntHash {
		friend class UnionExpr;
		friend class PathExpr;
		friend class LocationPathExpr;
	public:
		const static int ih_mask1=0x7ff;
		const static int ih_mask2=0xfffff800;
		const static int ih_hashWidth=2048;
		const static int ih_hashWidthE=11;
		const static int ih_pageSizeE=5;

		IntHash();
		IntHash(int hashWidthExpo);
		virtual ~IntHash();
		static int determineHashWidth(int i);
		//void freeIntHash(IntHash *ih);
		bool isUnique(int i);
		void reset();

	private:
		FastIntBuffer **storage;
		int m1;  /* mask1 */
		int m2;  /* mask2 */
		int pse; /* page size exponential */
		int hw;  
		int maxDepth;
		int e;
	};
}

#endif
